package smedi.ismedi.mobile.bff.controller.organization;

import com.smedi.ismedi.organization.api.dto.request.OrganizationListQueryRequest;
import com.smedi.ismedi.organization.api.dto.request.OrganizationOneQueryRequest;
import com.smedi.ismedi.organization.api.dto.response.HrOrganizationResponse;
import com.smedi.ismedi.organization.api.dto.response.resp.OrganizationResp;
import com.smedi.ismedi.organization.api.feign.RemoteHrOrganizationFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

/**
 * 企业组织BFF
 *
 * @author xulinjun
 */
@Slf4j
@RestController
@Api(tags = {"项目组织架构维护接口"})
@RequestMapping("/mobilebff/v1/hrOrganization")
@AllArgsConstructor
public class HrOrganizationController extends BaseController {
    private final RemoteHrOrganizationFeignApi remoteHrOrganizationFeignApi;

    /**
     * 获取所有企业组织下的项目管理组织清单
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取所有企业组织下的项目管理组织清单")
    @GetMapping(value = "/queryAllProjectManagementHROrganizationList")
    public ResponseData<List<HrOrganizationResponse>> getQueryAllProjectManagementHROrganizationList() {
        return remoteHrOrganizationFeignApi.getQueryAllProjectManagementHROrganizationList();
    }

    /**
     * 获取所有企业组织下的特定类型的组织清单
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取所有企业组织下的特定类型的组织清单")
    @GetMapping(value = "/queryAllHROrganizationListByType")
    ResponseData<List<HrOrganizationResponse>> getQueryAllHROrganizationListByType(@RequestParam("isCompany") boolean isCompany,
                                                                                   @RequestParam("isCompanyLeader") boolean isCompanyLeader,
                                                                                   @RequestParam("isCompanyManagementOrganization") boolean isCompanyManagementOrganization,
                                                                                   @RequestParam("isProjectManagementOrganization") boolean isProjectManagementOrganization,
                                                                                   @RequestParam("isSubordinateOrganization") boolean isSubordinateOrganization) {
        return remoteHrOrganizationFeignApi.getQueryAllHROrganizationListByType(isCompany, isCompanyLeader, isCompanyManagementOrganization, isProjectManagementOrganization, isSubordinateOrganization);
    }

    /**
     * 查询 企业 详情
     *
     * @param organizationOneQueryRequest 企业 详情 请求
     * @return ResponseData<List < OrganizationResp>>
     */
    @PostMapping(value = "/one")
    @ApiOperation(httpMethod = "POST", value = "查询 企业组织 单一")
    ResponseData<OrganizationResp> getOrganizationOne(@RequestBody OrganizationOneQueryRequest organizationOneQueryRequest) {
        return remoteHrOrganizationFeignApi.getOrganizationOne(organizationOneQueryRequest);
    }

    /**
     * 查询 企业 列表
     *
     * @param organizationListQueryRequest 企业 列表 请求
     * @return ResponseData<List < OrganizationResp>>
     */
    @PostMapping(value = "/list")
    @ApiOperation(httpMethod = "POST", value = "查询 企业组织 列表")
    ResponseData<List<OrganizationResp>> getOrganizationList(@RequestBody OrganizationListQueryRequest organizationListQueryRequest) {
        return remoteHrOrganizationFeignApi.getOrganizationList(organizationListQueryRequest);
    }
}
